<template>
  <div>
    <my-breadcrumb :items="['订单管理', '订单流水']"></my-breadcrumb>
    <Table :data="listData" :columns="listColumns"></Table>
    <page-info :page="page" @pageNumChange="pageChange" @pageSizeChange="pageChange"></page-info>
  </div>
</template>

<script>
import pageInfo from '../../common/pageInfo'
export default {
  name: 'distribution',
  data () {
    return {
      url: {
        list: '/branch/order/payment/distribution/list'
      },
      listData: [],
      listColumns: [
        {
          title: '创建时间',
          align: 'center',
          render: (h, params) => {
            return h('span', new Date(params.row.gmtCreate).toLocaleString())
          }
        },
        {
          title: '订单实付款',
          align: 'center',
          render: (h, params) => {
            return h('span', params.row.orderActualPayment / 100 + '￥')
          }
        },
        {
          title: '订单收入',
          align: 'center',
          render: (h, params) => {
            return h('span', {
              style: {
                color: '#19be6b',
                fontWeight: '800'
              }
            }, '+' + params.row.branchIncomeAmount / 100 + '￥')
          }
        },
        {
          title: '订单扣点金额',
          align: 'center',
          render: (h, params) => {
            return h('span', {
              style: {
                color: '#ed3f14',
                fontWeight: '800'
              }
            }, '-' + params.row.branchDeductAmount / 100 + '￥')
          }
        },
        {
          title: '订单类型',
          align: 'center',
          render: (h, params) => {
            return h('span', params.row.buyerType === 1 ? '公众号' : '分销商')
          }
        },
        {
          title: '支付来源',
          align: 'center',
          render: (h, params) => {
            return h('span', params.row.payFrom === 1 ? '微信支付' : '余额支付')
          }
        },
        {
          title: '支付完成时间',
          align: 'center',
          render: (h, params) => {
            return h('span', new Date(params.row.payCompleteTime).toLocaleString())
          }
        }
      ],

      page: {
        pageNum: 1,
        pageSize: 10,
        total: 0
      }
    }
  },
  methods: {
    pageChange (page) {
      this.page = page
      this.pageQuery()
    },
    pageQuery () {
      this.$ajax.post(this.url.list, {pageNum: this.page.pageNum, pageSize: this.page.pageSize})
        .then(res => {
          if (res.data.success) {
            this.page.total = res.data.data.total
            this.listData = res.data.data.list
          }
        })
    }
  },
  components: {
    pageInfo
  },
  created () {
    this.pageQuery()
  }
}
</script>

<style scoped>

</style>
